package services

import (
	"context"
	"k8sops/pkg/client"
	"log"

	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func GetNamespaces() (namespaceList *v1.NamespaceList, err error) {
	k := client.K8sClientSet{}
	c, err := k.GetClientset()
	if err != nil {
		log.Fatal(err.Error())
		return
	}

	namespaceList, err = c.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		log.Fatal(err.Error())
		return
	}

	return
}
